<template>
  <view class="container">
    <view class="header">📰 行业资讯</view>

    <scroll-view scroll-y class="news-list">
      <view
        class="news-card"
        v-for="(item, index) in newsList"
        :key="index"
        @click="viewDetail(item)"
      >
        <image :src="item.cover" class="cover-img" mode="aspectFill" />
        <view class="info">
          <view class="title">{{ item.title }}</view>
          <view class="summary">{{ item.summary }}</view>
          <view class="meta">{{ item.date }}</view>
        </view>
      </view>
    </scroll-view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      newsList: [
        {
          title: "电梯新国标2025年实施，全面提高安全要求",
          summary: "新版《电梯制造与维护规范》将于2025年7月1日正式实施，涉及维保周期、故障告警等关键调整。",
          date: "2025-07-20",
          cover: '/static/images/news/news_1.png'
        },
        {
          title: "国家市场监管总局通报电梯事故频发问题",
          summary: "近期多起电梯安全事故引发关注，监管总局要求各单位自查隐患，完善应急机制。",
          date: "2025-07-15",
          cover: "/static/images/news/news_2.png"
        },
        {
          title: "物联网电梯监控系统普及率达70%",
          summary: "电梯智能监控系统推广成果显著，大幅提升故障响应速度和维保效率。",
          date: "2025-07-10",
          cover: "/static/images/news/news_3.png"
        }
      ]
    };
  },
  methods: {
    viewDetail(item) {
      uni.showToast({
        title: '模拟打开资讯详情',
        icon: 'none'
      });

      // 实际项目中可跳转到详情页，如：
      // uni.navigateTo({
      //   url: '/pages/news/detail?title=' + encodeURIComponent(item.title)
      // });
    }
  }
};
</script>

<style scoped>
.container {
  padding: 30rpx;
  background-color: #f7f7f7;
  min-height: 100vh;
}

.header {
  font-size: 40rpx;
  font-weight: bold;
  text-align: center;
  margin-bottom: 30rpx;
}

.news-list {
  max-height: calc(100vh - 100rpx);
}

.news-card {
  display: flex;
  background-color: #fff;
  border-radius: 16rpx;
  margin-bottom: 24rpx;
  overflow: hidden;
  box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.05);
}

.cover-img {
  width: 200rpx;
  height: 160rpx;
  object-fit: cover;
}

.info {
  flex: 1;
  padding: 20rpx;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.title {
  font-size: 32rpx;
  font-weight: 600;
  color: #333;
}

.summary {
  font-size: 28rpx;
  color: #666;
  margin-top: 10rpx;
  line-height: 1.4;
}

.meta {
  font-size: 24rpx;
  color: #999;
  margin-top: 10rpx;
}
</style>
